#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 55, p = 1e9 + 7;

LL n;
LL m[N];

int main()
{
	cin >> n;
	for(int i = 1;i <= n;i ++) cin >> m[i];
	LL ans = 1;
	sort(m + 1, m + 1 + n);
	for(int i = 1;i <= n;i ++)
	{
		if(m[i] - i + 1 == 0)
		{
			ans = 0;
			break;
		}
		ans = ans * (m[i] - i + 1) % p;
	}
	cout << ans << endl;
	return 0;
}